<template>
  <div>
    <div class="flex flex-col h-full">
      <SearchContainer @search="getData" @reset="() => formRef.resetFields()">
        <a-form ref="formRef" class="form-style-flex" :model="formState" :colon="false" :label-col="{ style: { width: '70px' } }">
          <a-form-item name="empId" class="w-[300px] mr-2">
            <a-input v-model:value="formState.empId" placeholder="员工编号/员工姓名/助记码" />
          </a-form-item>
          <a-form-item name="dateRange" label="日期范围" class="w-[320px]">
            <a-range-picker v-model:value="formState.dateRange" format="YYYY-MM-DD" value-format="YYYY-MM-DD" />
          </a-form-item>
        </a-form>
      </SearchContainer>
      <a-card class="mt-2 flex-1">
        <BaseTable :loading="loading" column-code="000472" fill :data-source="tableData" bordered :pagination="pagination">
          <template #bodyCell="{ column, index }">
            <template v-if="column.dataIndex === 'xh'">
              {{ index + 1 }}
            </template>
          </template>
        </BaseTable>
      </a-card>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import dayjs from 'dayjs'
import SearchContainer from '@/components/SearchContainer'
import BaseTable from '@/components/BaseTable'

const formRef = ref(null)
const formState = ref({
  dateRange: [dayjs().format('YYYY-MM-DD'), dayjs().format('YYYY-MM-DD')]
  // empId: ''
})
const { loading, tableData, getData, pagination } = useTable({
  url: '/common/loginLog/getLoginRecord',
  immediate: true,
  params: formState.value,
  formatParams: (params) => {
    return {
      ...params,
      startDate: params.dateRange?.[0],
      endDate: params.dateRange?.[1]
    }
  }
})
</script>
<style lang="less" scoped></style>
